﻿Ext.define('Messages',{
	extend:'Ext.data.Model',
	fields:[
		{name:'id', type:'int'},
		{name:'status', type:'boolean'},
		{name:'attach', type:'boolean'},
		{name:'flag', type:'boolean'},
		'from',
		'to',
		'subject',
		{name:'recieved', type:'date', dateFormat:'D, d M Y, H:i'},
		{name:'created', type:'date', dateFormat:'D, d M Y, H:i'},
		{name:'size', type:'int'}
	]
});
var storeHeader = Ext.create('Ext.data.Store', {
	model:'Messages',
	autoLoad:true,
	proxy:{
		// load using HTTP
		type:'ajax',
		url:'headers.xml',
		// the return will be XML, so lets set up a reader
		reader:{
			type:'xml',
			// records will have an "Item" tag
			record:'item',
			idProperty:'id',
			totalRecords:'@total'
		}
	}
});
var mailheader = Ext.create('Ext.grid.Panel', {
	store:storeHeader,
	region:'center',
	columns:[
		{text:"S", width:25, dataIndex:'status', sortable:true},
		{text:"@", width:25, dataIndex:'attach', sortable:true},
		{text:"F", width:25, dataIndex:'flag', sortable:true},
		{text:"От", flex:1, dataIndex:'from', sortable:true},
		{text:"Кому", flex:1, dataIndex:'to', sortable:true},
		{text:"Тема", flex:2, dataIndex:'subject', sortable:true},
		{text:"Получено", width:100, dataIndex:'recieved', sortable:true},
		{text:"Создано", width:100, dataIndex:'created', sortable:true},
		{text:"Размер", width:100, dataIndex:'size', sortable:true}
	]
});
